package com.xzy.mapper;

import com.xzy.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value="UserMapper")
public interface UserMapper {
    @Select("select * from user where userName=#{userName} and userPass=#{userPass}")
    User login(String userName, String userPass);
    @Insert("insert into user(userName,userPass,realName,userEmail,userRights,userStatus,departmentId) values (#{userName},#{userPass},#{realName},#{userEmail},#{userRights},#{userStatus},#{departmentId})")
    void addUser(User user);
    @Update("update user set userName=#{userName},userPass=#{userPass},realName=#{realName},userEmail=#{userEmail},userRights=#{userRights},userStatus=#{userStatus},departmentId=#{departmentId} where userId=#{userId}")
    void updateUser(User user);
    @Select("select * from user where userRights=0")
    List<User> getAllUser();
    @Select("select * from user where userId=#{userId}")
    User getUser(int userId);
    @Delete("delete from user where userId=#{userId}")
    void deleteUser(int userId);

}
